const quickSort = (arr: number[]): number[] => {
    if (arr.length < 2) {
        return arr;
    }
    let middleIndex = Math.floor(arr.length / 2);
    const middle = arr[middleIndex];
    const left: number[] = [];
    const right: number[] = [];
    arr.forEach((item, index) => {
        if (index !== middleIndex) {
            if (item <= middle) {
                left.push(item)
            } else {
                right.push(item)
            }
        }
    })
    return quickSort(left).concat(middle, quickSort(right));
}

const arr = []
for (let index = 0; index < 100; index++) {
    arr.push(Math.floor(Math.random() * 100));
}

console.log("before", arr);

const sortArr = quickSort(arr);

console.log("after", sortArr);
